import React from 'react';
import { connect } from 'dva';
import styles from './billItem.css';
import Fmoney from '../../../../../../../framework/utils/fmoney';

const BillItem = ({
  item={},
  onViewMember=()=>{},
  showLimit=()=>{},
}) => {

  const countValue = (changedBalance, balance) => {
    const newValue = changedBalance - balance;
    if(newValue){
      return Fmoney(newValue, 2)
    }else{
      return '0'
    }
  }

  return (
    <div key={item.id.toString()} className={styles.billItem} >
      <div className={styles.billItemLeft}>
        <div className={styles.billItemTitle}>
          {item.changeNote}
        </div>
        <div className={styles.billItemDate}>
          {item.changedDate}
        </div>
      </div>
      <div className={styles.billItemRight}>
        {countValue(item.changedBalance, item.balance)}
      </div>
    </div>
  );
};

export default connect()(BillItem);
